package good.idea.data.demo.score;

import good.idea.data.excel.context.ExcelWriteContext;
import good.idea.data.excel.write.ExcelWriteHelper;
import good.idea.data.excel.write.ExcelWriteService;
import good.idea.data.excel.write.impl.ExcelWriteServiceImpl;

/**
 * 导出成绩单 demo
 *
 * @author chm
 */
public class ScoreExportDemo {

    public static void main(String[] args) throws Exception {

        ExcelWriteContext writeContext = ExcelWriteHelper.crateWriteContext();
        writeContext.addLoadListener((pageData, data, parent) -> {

            System.out.println("数据加载的监听" + data);

        });

        writeContext.addWriteListener((it) -> {
            System.out.println("写入行的数据" + it);
        });

        writeContext.createSheetDataChannel().addDataLoadChannel("data", new ScoreDataLoadChannel()).addDataLoadChannel("item.list", new ScoreSubDataLoadChannel());

        String tempPath = "excel-template/template_score.xlsx";
        writeContext.setTemplateName(tempPath);
        ExcelWriteService writeService = new ExcelWriteServiceImpl();
        writeService.write(writeContext);


    }
}
